package com.sc.nft.admin.controller;


import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.NftRegionBindingEditDTO;
import com.sc.nft.entity.dto.NftRegionBindingPageDTO;
import com.sc.nft.entity.dto.NftRegionBindingSaveDTO;
import com.sc.nft.entity.vo.NftRegionBindingPageVO;
import com.sc.nft.service.NftRegionBindingService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * nft版权部分绑定(NftRegionBinding)表控制层
 *
 * @author 王伟成
 * @since 2023-10-11 16:47:45
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/nftRegionBinding")
@Api(tags = "nft版权部分绑定")
@Valid
public class NftRegionBindingController {
    /**
     * 服务对象
     */
    private final NftRegionBindingService nftRegionBindingService;
    @PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "新增", notes = "新增", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result save(@RequestBody NftRegionBindingSaveDTO nftRegionBindingSaveDTO) {
        nftRegionBindingService.save(nftRegionBindingSaveDTO);
        return Result.success();
    }

    @PostMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "编辑", notes = "编辑", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result edit(@RequestBody NftRegionBindingEditDTO nftRegionBindingEditDTO) {
        nftRegionBindingService.edit(nftRegionBindingEditDTO);
        return Result.success();
    }

    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取该专场绑定的nft集合数据", notes = "获取该专场绑定的nft集合数据", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<NftRegionBindingPageVO> page(@RequestBody NftRegionBindingPageDTO nftRegionBindingPageDTO) {
        return PageResult.success(nftRegionBindingService.page(nftRegionBindingPageDTO));
    }


    @PostMapping(value = "/removeById", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除单条", notes = "删除单条", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result removeById(@RequestBody IdRequest idRequest) {
        nftRegionBindingService.removeById(idRequest.getId());
        return Result.success();
    }

}
